<?php
class Utils {
	public static function formataMoeda($valor) {
		return "R$ " . number_format ( $valor, 2, ',', '.' );
	}
	
	public static function formataData($data) {
		return date_format ( $data, "dd/m/yy" );
	}
	
	public static function formataTelefone($telefone) {
		return '(' . substr ( $telefone, 0, 2 ) . ') ' . substr ( $telefone, 2, 4 ) . '-' . substr ( $telefone, 6 );
	}
	
	public static function removeCaracteres($string, $caracteres) {
		if (is_array ( $caracteres )) {
			$tamanho = count ( $caracteres );
			for($i = 0; $i < $tamanho; $i ++) {
				$string = str_replace ( $caracteres [$i], '', $string );
			}
		} else {
			str_replace ( $caracteres, '', $string );
		}
		
		return $string;
	}
	
	public static function objectToArray($object) {
		if (count ( $object ) > 1) {
			
			$arr = array ();
			
			for($i = 0; $i < count ( $object ); $i ++) {
				
				$arr [] = get_object_vars ( $object [$i] );
			}
			
			return $arr;
		} else {
			
			return get_object_vars ( $object );
		}
	}
}

?>